from django.urls import path
from .views import Register, UserLogin, UserInfo, LogoutView, UserList, EmailCode, EmailFindPwd, FindPwd, AddUsers, \
    EditorAdmin, ChangeEmailCode, ChangeEmail, DeleteUsers, EditorUser, PassUser, AddUser, ResetPassword, ChangeStatus, \
    FileUploadView, FileDownloadView, GetUsers, GetExams, CreateResult, StartAnswering, WrongQuestion, RepeatWrongQuestion
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
    path('register/', Register.as_view(), name='register'),  # 注册
    path('login/', UserLogin.as_view(), name='login'),  # 登录
    path('emailCode/', EmailCode.as_view(), name='emailCode'),  # 发送验证码
    path('emailFindPwd/', EmailFindPwd.as_view(), name='emailFindPwd'),  # 找回密码发送验证码
    path('findPwd/', FindPwd.as_view(), name='findPwd'),  # 找回密码
    path('userInfo/<str:id>/', UserInfo.as_view(), name='userInfo'),  # 用户资料
    path('logout/', LogoutView.as_view(), name='logout'),  # 登出
    path('userList/', UserList.as_view(), name='user-list'),  # 用户列表
    path('addUsers/', AddUsers.as_view(), name='addUsers'),  # 批量添加用户
    path('changeEmailCode/', ChangeEmailCode.as_view(), name='changeEmailCode'),  # 修改邮箱验证码
    path('changeEmail/', ChangeEmail.as_view(), name='changeEmail'),  # 修改邮箱
    path('deleteUsers/', DeleteUsers.as_view(), name='deleteUsers'),  # 批量删除用户
    path('editorAdmin/', EditorAdmin.as_view(), name='editorAdmin'),  # 管理员根据id修改用户信息
    path('editorUser/', EditorUser.as_view(), name='editorUser'),  # 用户修改自己信息
    path('passUser/', PassUser.as_view(), name='passUser'),  # 用户修改自己密码
    path('addUser/', AddUser.as_view(), name='addUser'),  # 添加单个用户
    path('resetPassword/', ResetPassword.as_view(), name='resetPassword'),  # 重置密码
    path('changeStatus/', ChangeStatus.as_view(), name='changeStatus'),  # 切换用户状态
    path('getUserList/', GetUsers.as_view(), name='get-user-list'),  # 获取用户列表（不分页）
    path('getExamsList/', GetExams.as_view(), name='get-exam-list'),  # 获取需要参加的考试列表
    path('startAnswering/', StartAnswering.as_view(), name='startAnswering'),  # 开始答题，判断用户是否能答题
    path('submitCard/', CreateResult.as_view(), name='submitCard'),  # 提交答题卡
    path('wrongQuestion/', WrongQuestion.as_view(), name='wrongQuestion'),  # 错题记录
    path('repeatWrongQuestion/', RepeatWrongQuestion.as_view(), name='repeatWrongQuestion'),  # 重做错题
]

urlpatterns += [
                   path('upload/', FileUploadView.as_view(), name='file-upload'),
                   path('download/<int:file_id>/', FileDownloadView.as_view(), name='file-download'),
               ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
